package com.bcts.rrh.drawingboard.shapeview;

import com.bcts.rrh.drawingboard.testView;
import com.bcts.rrh.drawingboard.utils.RotateUtil;

import java.util.ArrayList;

import javax.microedition.khronos.opengles.GL10;

import static com.bcts.rrh.drawingboard.Constants.BALL_R;

public class ShapeList {
    testView testView;//testView的引用
    Shape_3d bnShape;//3D形状的引用

    int cubeId;//声明立方体ID
    int textureId;//申明球ID
    int textureZId;//晶体纹理ID
    float w; //屏幕宽度
    float h;// 屏幕高度
    float left; //视角left值
    float top; //视角top值
    float alpha;//摄像机的角度

    ArrayList<Shape_3d> alBN=null;//物体列表

    public ShapeList(testView testView, float w, float h, float left,float top,float alpha){
        this.testView=testView;
        this.w=w;
        this.h=h;
        this.left=left;
        this.top=top;
        this.alpha=alpha;
        textureId=testView.mRenderer.textureId;
        alBN=new ArrayList<Shape_3d>();

    }
    public void drawSelf(GL10 gl){
        for(int i=0;i<alBN.size();i++)
        {
            gl.glPushMatrix();
            alBN.get(i).drawSelf(gl);
            gl.glPopMatrix();
        }
    }
    /**
     * 创建一个球对象
     * @param testView
     * @param tx 触点x坐标
     * @param ty 触点y坐标
     */
    public void addBallShape(testView testView, float tx, float ty){//添加球,根据屏幕点击点的位置
        //1.将屏幕点击点坐标替换成图形坐标、
      /*  float[] bPosition=RotateUtil.calculatePosition(tx, ty, w, h, left, top,alpha);
        //2.以点击点为圆心创建球对象
        bnShape=new Ball(BALL_R,textureId,bPosition[0],bPosition[1],bPosition[2]);
        //3，将球对象添加到list里
        alBN.add(bnShape);*/

       // bnShape=new Ball(BALL_R,textureId,-6f,1f,-2f);//创建球
        alBN.add(bnShape);
    }


    public Shape_3d get(int i) {
        return alBN.get(i);
    }

    public int size() {
        return alBN.size();
    }
}
